﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PartyController.Models;

namespace PartyController.Controllers
{
    public class PartyController : Controller
    {
        //
        // GET: /Party/
        List<Party> Parties = new List<Party>();
        Party togaParty = new Party("Toga Party");
        Party poolParty = new Party("Pool Party");        
        
        List<Guest> GuestList = new List<Guest>() { 
            new Guest("Nicolaj"),
            new Guest("Birthe"),
            new Guest("Lisa")
        };

        [HttpPost]
        public ActionResult Index(string uiName)
        {
            if (GuestList.Contains(new Guest(uiName)) || uiName == null)
            {
                return View();
            }
            ViewData["Message"] = uiName;
            return View("Skrid");
        }

        [HttpGet]
        [Authorize]
        public ActionResult Index()
        {
            foreach (Guest guest in GuestList)
            {
                togaParty.AddGuest(guest);
                poolParty.AddGuest(guest);
            }
            Parties.Add(togaParty);
            Parties.Add(poolParty);
            ViewData["Parties"] = Parties;
            return View();
        }

        public ActionResult Skrid()
        {
            return View();
        }

    }
}
